package com.itheima.youdianda.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 对结果进行封装
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private Integer errno;
    private String errmsg;
    private Object data;

    public static Result ok(String errmsg, Object data) {
        return new Result(0, errmsg, data);
    }

    public static Result ok(Object data) {
        return new Result(0, "", data);
    }

    public static Result error(String errmsg) {
        return new Result(1000, errmsg, null);
    }

    public static Result notLogin() {
        return new Result(9998, "未登录，不允许操作！", null);
    }
}